using System;
using System.Collections.Generic;
using System.IO;
using Common;
using Common.Enum;

namespace SProject.Paramter
{
	[Serializable]
	public class HRMOptionItem : MeltingOptionItem
	{
		private double _StartTemperatureBefore = 79.0;

		private double _EndTemperatureBefore = 80.0;

		private double _StartTemperatureAfter = 86.0;

		private double _EndTemperatureAfter = 87.0;

		private double _QualityThreshold = 0.9;

		private double _TemperatureShiftThreshold = 5.0;

		private EHRMTypeMethod _TypeMethod;

		private EHRMClassificationMethod _ClassificationMethod;

		private int _ClassNum;

		private double _ClassThreshold = 0.3;

		private List<double> _ClassThresholdNumList = new List<double>();

		public double StartTemperatureBefore
		{
			get
			{
				return _StartTemperatureBefore;
			}
			set
			{
				if (_StartTemperatureBefore != value)
				{
					_StartTemperatureBefore = value;
					OnPropertyChanged("StartTemperatureBefore");
				}
			}
		}

		public double EndTemperatureBefore
		{
			get
			{
				return _EndTemperatureBefore;
			}
			set
			{
				if (_EndTemperatureBefore != value)
				{
					_EndTemperatureBefore = value;
					OnPropertyChanged("EndTemperatureBefore");
				}
			}
		}

		public double StartTemperatureAfter
		{
			get
			{
				return _StartTemperatureAfter;
			}
			set
			{
				if (_StartTemperatureAfter != value)
				{
					_StartTemperatureAfter = value;
					OnPropertyChanged("StartTemperatureAfter");
				}
			}
		}

		public double EndTemperatureAfter
		{
			get
			{
				return _EndTemperatureAfter;
			}
			set
			{
				if (_EndTemperatureAfter != value)
				{
					_EndTemperatureAfter = value;
					OnPropertyChanged("EndTemperatureAfter");
				}
			}
		}

		public double QualityThreshold
		{
			get
			{
				return _QualityThreshold;
			}
			set
			{
				if (_QualityThreshold != value)
				{
					_QualityThreshold = value;
					OnPropertyChanged("QualityThreshold");
				}
			}
		}

		public double TemperatureShiftThreshold
		{
			get
			{
				return _TemperatureShiftThreshold;
			}
			set
			{
				if (_TemperatureShiftThreshold != value)
				{
					_TemperatureShiftThreshold = value;
					OnPropertyChanged("TemperatureShiftThreshold");
				}
			}
		}

		public EHRMTypeMethod TypeMethod
		{
			get
			{
				return _TypeMethod;
			}
			set
			{
				if (_TypeMethod != value)
				{
					_TypeMethod = value;
					OnPropertyChanged("TypeMethod");
				}
			}
		}

		public EHRMClassificationMethod ClassificationMethod
		{
			get
			{
				return _ClassificationMethod;
			}
			set
			{
				if (_ClassificationMethod != value)
				{
					_ClassificationMethod = value;
					OnPropertyChanged("ClassificationMethod");
				}
			}
		}

		public int ClassNum
		{
			get
			{
				return _ClassNum;
			}
			set
			{
				if (_ClassNum != value)
				{
					_ClassNum = value;
					OnPropertyChanged("ClassNum");
				}
			}
		}

		public double ClassThreshold
		{
			get
			{
				return _ClassThreshold;
			}
			set
			{
				if (_ClassThreshold != value)
				{
					_ClassThreshold = value;
					OnPropertyChanged("ClassThreshold");
				}
			}
		}

		public List<double> ClassThresholdNumList
		{
			get
			{
				return _ClassThresholdNumList;
			}
			set
			{
				if (_ClassThresholdNumList != value)
				{
					_ClassThresholdNumList = value;
					OnPropertyChanged("ClassThresholdNumList");
				}
			}
		}

		public HRMOptionItem()
		{
			base.MinTemperature = StartTemperatureBefore;
			base.MaxTemperature = EndTemperatureAfter;
			base.PeekHightThreshold = 5.0;
		}

		public override void SetDefaultData()
		{
			base.SetDefaultData();
			base.MinTemperature = StartTemperatureBefore;
			base.MaxTemperature = EndTemperatureAfter;
			base.PeekHightThreshold = 5.0;
			StartTemperatureBefore = 79.0;
			EndTemperatureBefore = 80.0;
			StartTemperatureAfter = 86.0;
			EndTemperatureAfter = 87.0;
			QualityThreshold = 0.9;
			TemperatureShiftThreshold = 5.0;
			TypeMethod = EHRMTypeMethod.Auto;
			ClassificationMethod = EHRMClassificationMethod.System;
			ClassThreshold = 0.3;
		}

		public override void Copy(BasicOptionItem item)
		{
			base.Copy(item);
			HRMOptionItem hRMOptionItem = item as HRMOptionItem;
			StartTemperatureBefore = hRMOptionItem.StartTemperatureBefore;
			EndTemperatureBefore = hRMOptionItem.EndTemperatureBefore;
			StartTemperatureAfter = hRMOptionItem.StartTemperatureAfter;
			EndTemperatureAfter = hRMOptionItem.EndTemperatureAfter;
			QualityThreshold = hRMOptionItem.QualityThreshold;
			TemperatureShiftThreshold = hRMOptionItem.TemperatureShiftThreshold;
			TypeMethod = hRMOptionItem.TypeMethod;
			ClassificationMethod = hRMOptionItem.ClassificationMethod;
			ClassNum = hRMOptionItem.ClassNum;
			ClassThreshold = hRMOptionItem.ClassThreshold;
			ClassThresholdNumList = new List<double>(hRMOptionItem.ClassThresholdNumList);
		}

		protected override void GetData(List<PropertyKey> keys, List<byte[]> datas)
		{
			base.GetData(keys, datas);
			keys.Add(PropertyKey.Key_StartTemperatureBefore);
			datas.Add(BytesConverter.GetBytes(StartTemperatureBefore));
			keys.Add(PropertyKey.Key_EndTemperatureBefore);
			datas.Add(BytesConverter.GetBytes(EndTemperatureBefore));
			keys.Add(PropertyKey.Key_StartTemperatureAfter);
			datas.Add(BytesConverter.GetBytes(StartTemperatureAfter));
			keys.Add(PropertyKey.Key_EndTemperatureAfter);
			datas.Add(BytesConverter.GetBytes(EndTemperatureAfter));
			keys.Add(PropertyKey.Key_QualityThreshold);
			datas.Add(BytesConverter.GetBytes(QualityThreshold));
			keys.Add(PropertyKey.Key_TemperatureShiftThreshold);
			datas.Add(BytesConverter.GetBytes(TemperatureShiftThreshold));
			keys.Add(PropertyKey.Key_TypeMethod);
			datas.Add(BytesConverter.GetBytes((int)TypeMethod));
			keys.Add(PropertyKey.Key_ClassificationMethod);
			datas.Add(BytesConverter.GetBytes((int)ClassificationMethod));
			keys.Add(PropertyKey.Key_ClassNum);
			datas.Add(BytesConverter.GetBytes(ClassNum));
			keys.Add(PropertyKey.Key_ClassThreshold);
			datas.Add(BytesConverter.GetBytes(ClassThreshold));
		}

		protected override void SetData(PropertyKey key, byte[] data)
		{
			base.SetData(key, data);
			switch (key)
			{
			case PropertyKey.Key_StartTemperatureBefore:
				StartTemperatureBefore = BytesConverter.BytesToDouble(data);
				break;
			case PropertyKey.Key_EndTemperatureBefore:
				EndTemperatureBefore = BytesConverter.BytesToDouble(data);
				break;
			case PropertyKey.Key_StartTemperatureAfter:
				StartTemperatureAfter = BytesConverter.BytesToDouble(data);
				break;
			case PropertyKey.Key_EndTemperatureAfter:
				EndTemperatureAfter = BytesConverter.BytesToDouble(data);
				break;
			case PropertyKey.Key_QualityThreshold:
				QualityThreshold = BytesConverter.BytesToDouble(data);
				break;
			case PropertyKey.Key_TemperatureShiftThreshold:
				TemperatureShiftThreshold = BytesConverter.BytesToDouble(data);
				break;
			case PropertyKey.Key_TypeMethod:
				TypeMethod = (EHRMTypeMethod)BytesConverter.BytesToInt(data);
				break;
			case PropertyKey.Key_ClassificationMethod:
				ClassificationMethod = (EHRMClassificationMethod)BytesConverter.BytesToInt(data);
				break;
			case PropertyKey.Key_ClassNum:
				ClassNum = BytesConverter.BytesToInt(data);
				break;
			case PropertyKey.Key_ClassThreshold:
				ClassThreshold = BytesConverter.BytesToDouble(data);
				break;
			}
		}

		public override void SaveToStream(StreamEx stream)
		{
			base.SaveToStream(stream);
		}

		public override bool ReadFromStream(StreamEx stream)
		{
			if (base.ReadFromStream(stream))
			{
				while (true)
				{
					switch (stream.ReadKey())
					{
					case PropertyKey.Key_StartTemperatureBefore:
						StartTemperatureBefore = stream.ReadDouble();
						break;
					case PropertyKey.Key_EndTemperatureBefore:
						EndTemperatureBefore = stream.ReadDouble();
						break;
					case PropertyKey.Key_StartTemperatureAfter:
						StartTemperatureAfter = stream.ReadDouble();
						break;
					case PropertyKey.Key_EndTemperatureAfter:
						EndTemperatureAfter = stream.ReadDouble();
						break;
					case PropertyKey.Key_QualityThreshold:
						QualityThreshold = stream.ReadDouble();
						break;
					case PropertyKey.Key_TemperatureShiftThreshold:
						TemperatureShiftThreshold = stream.ReadDouble();
						break;
					case PropertyKey.Key_TypeMethod:
						TypeMethod = (EHRMTypeMethod)stream.ReadInt();
						break;
					case PropertyKey.Key_ClassificationMethod:
						ClassificationMethod = (EHRMClassificationMethod)stream.ReadInt();
						break;
					case PropertyKey.Key_ClassNum:
						ClassNum = stream.ReadInt();
						break;
					case PropertyKey.Key_ClassThreshold:
						ClassThreshold = stream.ReadDouble();
						break;
					default:
						stream.Seek(-4L, SeekOrigin.Current);
						return true;
					}
				}
			}
			return false;
		}
	}
}
